package com.wgy.designmode.action.memento;

/**
 * 发起人
 */
public class Originator {

    private String state;

    public Originator() {
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    /**
     * 创建一个备忘录保存状态
     * @return
     */
    public Memento saveStateToMemento(){
        return new Memento(state);
    }

    /**
     * 从备忘录中恢复状态
     * @param memento
     */
    public void restoreStateFromMemento(Memento memento) {
        state = memento.getState();
    }

}
